<script setup>
import { onMounted, onUnmounted, ref } from 'vue';
const mouse = ref({
    x: 100,
    y: 100
})
const move = (e) => {
    mouse.value.x = e.clientX
    mouse.value.y = e.clientY
}
onMounted(() => {
    document.addEventListener('mousemove', move)
})
onUnmounted(() => {
    document.removeEventListener('mousemove', move)
})

const count = ref(0)
const add = () => {
    count.value++
}

</script>

<template>
    <div>当前鼠标位置</div>
    <div>x: {{ mouse.x }}</div>
    <div>y: {{ mouse.y }}</div>
    <div>当前点击次数：{{ count }}</div>
    <button @click="add">点击</button>
</template>